package com.xiaotao.learn.algorithm.sort;

import java.util.Arrays;

public class Bubbling {
    public static void main(String[] args) {
        int[] a = new int[]{1,3,2,4,6,5,8,7};
        bubbling(a);
        System.out.println(Arrays.toString(a));
    }


    static void bubbling(int[] arr) {
        int t;
        for (int i = arr.length - 1; i >= 0; i--) {
            for (int j = 0; j < i; j++) {
                if (arr[j] > arr[j + 1]) {
                    t = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = t;
                }
            }
        }
    }
}
